package com.systar.activity.ui;

import java.io.InputStream;

import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Widget;

public class AnimatedActionButton extends AnimatedImage
{
	private ActionContributionItem action;
	
	public AnimatedActionButton(InputStream... fileStreams)
	{
		super(fileStreams);
	}
	
	public void setAction(ActionContributionItem action)
	{
		this.action = action;
	}

	@Override
	public void fireImageChanged()
	{
		if (action != null)
		{
			Widget widget = action.getWidget();
			if (widget == null)
				return;
			if (widget instanceof ToolItem) 
			{
				((ToolItem)widget).setImage(this.createImage());
			}
		}
	}

}
